package com.tonicgb.shared.exception;

import com.tonicgb.shared.common.enums.MessageCodeEnum;
import com.tonicgb.shared.common.enums.WechatCodeEnum;

/**
 * @author zhaiyujin
 * @date 2021-08-31 14:05:13
 * @说明：apiException
 */
public class ApiException extends RuntimeException{

    private final int errorCode;

    public ApiException(int errorCode,String message) {
        super(message);
        this.errorCode = errorCode;
    }

    public ApiException(String message) {
        super(message);
        this.errorCode = 400;
    }

        public ApiException(MessageCodeEnum messageCodeEnum){
        super(messageCodeEnum.getText());
        this.errorCode=messageCodeEnum.getCode();
    }

    public ApiException(WechatCodeEnum messageCodeEnum){
        super(messageCodeEnum.getText());
        this.errorCode=messageCodeEnum.getCode();
    }

    public int getErrorCode() {
        return errorCode;
    }
}
